//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.gui.fixed;

import javax.swing.*;

// Referenced classes of package org.jpgolay.gui.fixed:
//            Messages
public class BasicMenu extends JMenuBar {

    public BasicMenu() {
        fileJMenu = null;
        newJMenuItem = null;
        openJMenuItem = null;
        saveJMenuItem = null;
        printJMenuItem = null;
        exitJMenuItem = null;
        editJMenu = null;
        helpJMenu = null;
        modifyJMenuItem = null;
        deleteJMenuItem = null;
        helpContentJMenuItem = null;
        initialize();
    }

    private void initialize() {
        setSize(120, 20);
        add(getFileJMenu());
        add(getEditJMenu());
        add(getHelpJMenu());
    }

    private JMenu getFileJMenu() {
        if (fileJMenu == null) {
            fileJMenu = new JMenu();
            fileJMenu.setText(Messages.getString("BasicMenu.file"));
            fileJMenu.add(getNewJMenuItem());
            fileJMenu.add(getOpenJMenuItem());
            fileJMenu.add(getSaveJMenuItem());
            fileJMenu.add(getPrintJMenuItem());
            fileJMenu.add(getExitJMenuItem());
        }
        return fileJMenu;
    }

    private JMenuItem getNewJMenuItem() {
        if (newJMenuItem == null) {
            newJMenuItem = new JMenuItem();
            newJMenuItem.setText(Messages.getString("BasicMenu.new"));
            newJMenuItem.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/new.png")));
        }
        return newJMenuItem;
    }

    private JMenuItem getOpenJMenuItem() {
        if (openJMenuItem == null) {
            openJMenuItem = new JMenuItem();
            openJMenuItem.setText(Messages.getString("BasicMenu.open"));
            openJMenuItem.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/open.png")));
        }
        return openJMenuItem;
    }

    private JMenuItem getSaveJMenuItem() {
        if (saveJMenuItem == null) {
            saveJMenuItem = new JMenuItem();
            saveJMenuItem.setName("");
            saveJMenuItem.setText(Messages.getString("BasicMenu.save"));
            saveJMenuItem.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/save.png")));
        }
        return saveJMenuItem;
    }

    private JMenuItem getPrintJMenuItem() {
        if (printJMenuItem == null) {
            printJMenuItem = new JMenuItem();
            printJMenuItem.setText(Messages.getString("BasicMenu.print"));
            printJMenuItem.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/printer.png")));
        }
        return printJMenuItem;
    }

    private JMenuItem getExitJMenuItem() {
        if (exitJMenuItem == null) {
            exitJMenuItem = new JMenuItem();
            exitJMenuItem.setText(Messages.getString("BasicMenu.exit"));
            exitJMenuItem.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/empty18x18.png")));
        }
        return exitJMenuItem;
    }

    private JMenu getEditJMenu() {
        if (editJMenu == null) {
            editJMenu = new JMenu();
            editJMenu.setText(Messages.getString("BasicMenu.edit"));
            editJMenu.add(getModifyJMenuItem());
            editJMenu.add(getDeleteJMenuItem());
        }
        return editJMenu;
    }

    private JMenu getHelpJMenu() {
        if (helpJMenu == null) {
            helpJMenu = new JMenu();
            helpJMenu.setText(Messages.getString("BasicMenu.help"));
            helpJMenu.add(getHelpContentJMenuItem());
        }
        return helpJMenu;
    }

    private JMenuItem getModifyJMenuItem() {
        if (modifyJMenuItem == null) {
            modifyJMenuItem = new JMenuItem();
            modifyJMenuItem.setText(Messages.getString("BasicMenu.modify"));
            modifyJMenuItem.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/modify.png")));
        }
        return modifyJMenuItem;
    }

    private JMenuItem getDeleteJMenuItem() {
        if (deleteJMenuItem == null) {
            deleteJMenuItem = new JMenuItem();
            deleteJMenuItem.setText(Messages.getString("BasicMenu.delete"));
            deleteJMenuItem.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/delete.png")));
        }
        return deleteJMenuItem;
    }

    private JMenuItem getHelpContentJMenuItem() {
        if (helpContentJMenuItem == null) {
            helpContentJMenuItem = new JMenuItem();
            helpContentJMenuItem.setText(Messages.getString("BasicMenu.help_content"));
            helpContentJMenuItem.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/help.png")));
        }
        return helpContentJMenuItem;
    }

    public JMenuItem getNew() {
        return getNewJMenuItem();
    }

    public JMenuItem getOpen() {
        return getOpenJMenuItem();
    }

    public JMenuItem getSave() {
        return getSaveJMenuItem();
    }

    public JMenuItem getPrint() {
        return getPrintJMenuItem();
    }

    public JMenuItem getExit() {
        return getExitJMenuItem();
    }

    public JMenuItem getModify() {
        return getModifyJMenuItem();
    }

    public JMenuItem getDelete() {
        return getDeleteJMenuItem();
    }

    public JMenuItem getHelp() {
        return getHelpContentJMenuItem();
    }
    private JMenu fileJMenu;
    private JMenuItem newJMenuItem;
    private JMenuItem openJMenuItem;
    private JMenuItem saveJMenuItem;
    private JMenuItem printJMenuItem;
    private JMenuItem exitJMenuItem;
    private JMenu editJMenu;
    private JMenu helpJMenu;
    private JMenuItem modifyJMenuItem;
    private JMenuItem deleteJMenuItem;
    private JMenuItem helpContentJMenuItem;
}
